package org.cid54.jshopper.dao.impl;

import org.cid54.jshopper.dao.ItemDao;
import org.cid54.jshopper.model.Item;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 *
 * @author fgo
 */
@Repository
public class ItemDaoImpl extends SuperEntityDaoImpl<Item> implements ItemDao{

    @Override
    protected Class getEntityClass() {
        return Item.class;
    }

    @Override
    public boolean isSortableByName(){
        return true;
    }

    @Override
    public Item findByName(String name) {
        Criteria criteria = this.getNewCriteria();

        criteria.add(Restrictions.eq("name", name));

        return (Item) criteria.uniqueResult();
    }

}
